using CoreManager.AI.Models;

namespace CoreManager.AI.Services;

/// <summary>
/// 会话历史服务接口
/// </summary>
public interface ISessionHistoryService
{
    /// <summary>
    /// 获取会话历史
    /// </summary>
    /// <param name="sessionId">会话ID</param>
    /// <returns>会话历史，如果不存在则返回新的会话</returns>
    Task<SessionHistory> GetSessionHistoryAsync(string sessionId);

    /// <summary>
    /// 保存或更新会话历史
    /// </summary>
    /// <param name="sessionHistory">会话历史</param>
    Task SaveSessionHistoryAsync(SessionHistory sessionHistory);

    /// <summary>
    /// 添加消息到会话
    /// </summary>
    /// <param name="sessionId">会话ID</param>
    /// <param name="message">消息</param>
    Task AddMessageAsync(string sessionId, ChatMessage message);

    /// <summary>
    /// 清除会话历史
    /// </summary>
    /// <param name="sessionId">会话ID</param>
    Task ClearSessionHistoryAsync(string sessionId);

    /// <summary>
    /// 获取所有会话列表
    /// </summary>
    /// <param name="limit">限制数量（可选）</param>
    /// <returns>会话历史列表</returns>
    Task<List<SessionHistory>> GetAllSessionsAsync(int? limit = null);

    /// <summary>
    /// 删除会话
    /// </summary>
    /// <param name="sessionId">会话ID</param>
    Task DeleteSessionAsync(string sessionId);

    /// <summary>
    /// 清理过期会话
    /// </summary>
    /// <param name="expirationHours">过期时间（小时）</param>
    /// <returns>清理的会话数量</returns>
    Task<int> CleanupExpiredSessionsAsync(int expirationHours = 24);
}

